from sqlalchemy import create_engine, Column
from sqlalchemy.orm import declarative_base,sessionmaker, Mapped, mapped_column
from sqlalchemy.sql import func
from typing_extensions import Annotated
import sqlalchemy
import datetime

engine = create_engine("mysql://root:root@localhost/test", echo=True)

Base = declarative_base()

default_now = Annotated[datetime.datetime, mapped_column(nullable=False, server_default=func.now())]

class Customer(Base):

    __tablename__ = "customer"

    id:Mapped[int] = mapped_column(sqlalchemy.Integer, primary_key=True)
    name:Mapped[str] = mapped_column(sqlalchemy.String(32), nullable=False, unique=True)
    createTime:Mapped[default_now]


Base.metadata.create_all(engine)
Session = sessionmaker()

